<?php

function retrieve_po_data(&$data, $kode){
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);    
    $result = $CI->model_transaksi_internal->getPOSuppData("WHERE q.id_po = '". mysql_escape_string($kode)."'");
    $row = $result->row();
    
    
    $data["id_po"] = $row->id_po;
    $data["id_supplier"] = $row->id_supplier;
    $data["nama_supplier"] = $row->nama_supplier;
    $data["tanggal_po"] = $row->tanggal_po;
    $data["nomor_po"] = $row->nomor_po;
    $data["alamat_detail_supplier"] = $row->alamat_detail_supplier;
    $data["rf_number"] = $row->rf_number;
    $data["alamat_komplit"] = $row->alamat_supplier."\n".$row->kota_supplier."\n".$row->kode_pos_supplier;
    $data["kontak_komplit"] = $row->telepon_supplier."/".$row->fax_supplier."/".$row->email_supplier;
    $data["attendance"] = $row->attendance;
    $data["subject"] = $row->subject;
    $data["pic_perusahaan"] = $row->pic_perusahaan;
    $data["urgensi"] = $row->urgensi;    
    $data["nama_vessel"] = $row->nama_vessel;
    $data["bendera_vessel"] = $row->bendera_vessel;
    $data["gt_vessel"] = $row->gt_vessel;
    $data["id_vessel"] = $row->id_vessel;
    $data["nama_port"] = $row->nama_port;
    $data["id_port"] = $row->id_port;
    $data["diskon"] = $row->diskon ? $row->diskon : 0;
    $data["using_dollar_currency"] = $row->using_dollar_currency;
    
    $data["item"] = $CI->model_transaksi_internal->getPOSuppItem($kode);
    
    $data["crc"] = $row->using_dollar_currency ? "$" : "Rp.";
    $data["using_ppn"] = $row->using_ppn;
    $data["tc"] = $row->isi_tc;
    $data["ppn"] = $row->ppn;
    $data["quote_by"] = $row->quote_by;
    $data["approved_by"] = $row->approved_by;
    
    $data["use_header"] = $CI->model_transaksi_internal->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'PO_TO_SUPPLIER'", "tampilkan_header");
}

function retrieve_invoice_data(&$data, $kode){    
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);    
    $result = $CI->model_transaksi_internal->getInvoiceSuppData("WHERE p.id_invoice = '". mysql_escape_string($kode)."'");
    $row = $result->row();
    
    $data["id_invoice"] = $row->id_invoice;
    $data["nomor_invoice"] = $row->nomor_invoice;
    $data["tanggal_invoice"] = $row->tanggal_invoice;
    $data["diskon"] = $row->diskon ? $row->diskon : 0;
    
    $data["list_po"] = $CI->model_transaksi_internal->getPOSuppData("WHERE q.id_po IN (".($row->list_po_id ? $row->list_po_id : 0).")");
    $data["item"] = $CI->model_transaksi_internal->getInvoiceSuppItem($data["id_invoice"]);
    
    $data["using_dollar_currency"] = $row->using_dollar_currency;
    $data["nama_supplier"] = $row->nama_supplier;
    $data["alamat_detail_supplier"] = $row->alamat_detail_supplier;
    $data["alamat_komplit"] = $row->alamat_supplier."\n".$row->kota_supplier."\n".$row->kode_pos_supplier;
    $data["kontak_komplit"] = $row->telepon_supplier."/".$row->fax_supplier;
    $data["email"] = $row->email_supplier;
    $data["attendance"] = $row->attendance;
    $data["catatan_invoice"] = $row->catatan_invoice;
    $data["file_attachment_invoice"] = $row->file_attachment_invoice;
    
    $data["use_header"] = $CI->model_transaksi_internal->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'INVOICE_DARI_SUPPLIER'", "tampilkan_header");
}
?>
